package com.lv.suyiyong.hfr.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.lv.common.base.DataBindBaseViewHolder
import com.lv.common.imp.OnPositionTListener
import com.lv.service.bean.AddressDetailsBean
import com.lv.suyiyong.hfr.R
import com.lv.suyiyong.hfr.databinding.ItemAddressCompanyHomeBinding

/**
 * 作者： ygx
 * 创建日期：2022/6/24 8:10 PM
 * 签名： 天行健，君子以自强不息；地势坤，君子以厚德载物。
 *      _              _           _     _   ____  _             _ _
 *     / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 *    / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 *   / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 *  /_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 *
 * You never know what you can do until you try !
 * ----------------------------------------------------------------
 *
 */
class CompanyHomeAddressAdapter(private val datas: MutableList<AddressDetailsBean>) :
    BaseQuickAdapter<AddressDetailsBean, DataBindBaseViewHolder>
        (R.layout.item_address_company_home, datas) {

    override fun convert(holder: DataBindBaseViewHolder, item: AddressDetailsBean) {
        val mBinding: ItemAddressCompanyHomeBinding =
            holder.getBind() as ItemAddressCompanyHomeBinding
//        mBinding.itemRoot = item
//        //防止列表闪烁
        mBinding.executePendingBindings()
        val layoutPosition = holder.layoutPosition
        val address = "${item.province}${item.city}${item.area}${item.prefecture}${item.address}"
        mBinding.tvAddressDec.text = address
        var title = ""
        when (item.type) {
            "0" -> title = "地       址："
            "1" -> title = "工厂地址："
            "2" -> title = "店面地址："
            "3" -> title = "厂家地址："
            else -> title = "地       址："
        }
        mBinding.tvAddress.text = title

        mBinding.clContainer.setOnClickListener {
            onViewClickListener?.onClick(layoutPosition, address)
        }
    }

    var onViewClickListener: OnPositionTListener<String>? = null


}